package com.jinsi.util;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import java.io.InputStream;

/**
 *  上传视频接口
 */

public class UploadFile {



    public String fileUpload(@RequestParam("file") MultipartFile file
                             )

    { String path = null;
        if (file.isEmpty()) {

        }
        try {
            // 就用byte数组传输吧
            byte[] file_buff = null;
            InputStream inputStream=file.getInputStream();
            if(inputStream!=null){
                int len1 = inputStream.available();
                file_buff = new byte[len1];
                inputStream.read(file_buff);
            }
            inputStream.close();
            String[] results=FastDFSUtils.upload(file_buff);

            //拼接图片访问地址
            path =FastDFSClienta.getUrl()+results[0]+ "/"+results[1];
        } catch (Exception e) {

        }
        return path;
    }
}
